<template>
  <div class="home">
    <!-- 面包屑 -->
    <mbx name1="权限管理" name2="权限列表"></mbx>
    <!-- 卡片 -->
    <!-- 卡片区 -->
    <el-card class="mt16">
      <el-table :data="user" border style="width: 100%">
        <el-table-column fixed type="index" label="#" width="50px">
        </el-table-column>
        <el-table-column prop="authName" label="权限名称"> </el-table-column>
        <el-table-column prop="path" label="路径"> </el-table-column>
        <el-table-column prop="level" label="权限等级">
          <template #default="scope">
            <el-tag v-show="scope.row.level == 0">等级一</el-tag>
            <el-tag type="success" v-show="scope.row.level == 1">等级二</el-tag>
            <el-tag type="danger" v-show="scope.row.level == 2">等级三</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { toRefs, reactive, onMounted } from "vue";
import { getrights } from "../http/api.js";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
export default {
  setup(props) {
    //   路由
    const router = useRouter();
    const obj = reactive({
      user: [],
    });
    onMounted(() => {
      getlist();
    });
    // 渲染数据
    const getlist = async () => {
      const res = await getrights();
      console.log("rights", res);
      obj.user = res;
    };
    return {
      ...toRefs(obj),
    };
  },
};
</script>
<style lang="scss" scoped></style>
